<script setup>
import goDetail from '@/utils/goDetail'
//二级分类组件
defineProps({
  goods: {
    type: Object,
    default: () => {}
  }
})
</script>

<template>
  <div class="goods-item" @click="goDetail(goods.id)">
    <img v-lazyImg="goods.picture" alt="" />
    <div class="text">
      <div class="name">{{ goods.name }}</div>
      <div class="desc">{{ goods.desc }}</div>
      <div class="price">&yen;{{ goods.price }}</div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.goods-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  width: 220px;
  padding: 35px 10px;
  margin-top: 10px;
  margin-bottom: 10px;

  transition: all 0.5s;
  text-decoration: none;

  &:hover {
    transform: translate3d(0, -3px, 0);
    box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
  }

  img {
    width: 160px;
    height: 160px;
  }

  .text {
    width: 160px;
    white-space: nowrap; /* 防止文本换行 */

    .name {
      padding: 10px 0;
      font-size: 16px;
      color: #333;
      overflow: hidden; /* 隐藏溢出的内容 */
      text-overflow: ellipsis; /* 使用省略号替换溢出的文本 */
    }

    .desc {
      color: #999;
      height: 29px;
      overflow: hidden; /* 隐藏溢出的内容 */
      text-overflow: ellipsis; /* 使用省略号替换溢出的文本 */
    }

    .price {
      text-align: center;
      padding-top: 10px;
      font-size: 20px;
      color: #cf4444;
    }
  }
}
</style>
